package rui.game.rendering;

import javax.swing.*;
import java.awt.*;

import static java.awt.Color.*;

public class MyColor {


    // ===游戏的规则=============================================
    // 变颜色的方法
    public static void changeColor(JButton[][] btnary) {
        for (int a = 0; a < 4; a++)
            for (int b = 0; b < 4; b++) {// for循环遍历16个按钮
                String str = btnary[a][b].getText();
                btnary[a][b].setBackground(getColor(str));
            }
    }

    private static Color getColor(String str) {
        switch (str) {
            case "2":
                return white;
            case "4":
                return blue;
            case "8":
                return green;
            case "16":
                return pink;
            case "32":
                return white;
            case "64":
                return blue;
            case "128":
                return green;
            case "256":
                return pink;
            case "512":
                return white;
            case "1024":
                return blue;
            case "2048":
                return green;
            default:
                return white;
        }
    }
}
